package com.mdb.open.trade.service.trade;


/*
* Copyright (C), 2017-2019 澳发科技(MDB)
* FileName: TfInwardClaimService.java
* Author:   you.yichao
* Date:     2019-10-11
* History:
* <author>          <time>          <version>          <desc>
* you.yichao         2019-10-11          V1.00             代码生成器初始生成代码
* -----------------------------------------------------------
* 作者姓名           修改时间           版本号            描述
*/


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mdb.bc.api.data.ResultEx;
import com.mdb.bc.cache.sequence.util.SequenceGenerator;
import com.mdb.bc.database.mybatisplus.PageUtil;
import com.mdb.bc.database.mybatisplus.SuperService;
import com.mdb.open.common.enums.TfSequenceEnum;
import com.mdb.open.trade.common.MdbDataSource;
import com.mdb.open.trade.domain.bo.trade.QueryInwardClaimPageListBo;
import com.mdb.open.trade.domain.bo.trade.SaveInwardClaimBo;
import com.mdb.open.trade.domain.ko.trade.InwardClaimPageListKo;
import com.mdb.open.trade.domain.po.trade.InwardClaim;
import com.mdb.open.trade.mapper.trade.TfInwardClaimMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 类描述：
 *  汇入认领表 服务类
 *
 * @author you.yichao
 * @date 2019-10-11
 */
@Service
@DS(MdbDataSource.TRADE)
public class TfInwardClaimService extends SuperService<TfInwardClaimMapper, InwardClaim> {

    @Autowired
    SequenceGenerator sequenceGenerator;

    public ResultEx<InwardClaim> saveInwardClaim(SaveInwardClaimBo bo) {

        InwardClaim saveClaim = new InwardClaim();
        saveClaim.setRemitNo(bo.getRemitNo());
        saveClaim.setClaimNo(sequenceGenerator.generator(TfSequenceEnum.INWARD_CLAIM_REMIT_NO));
        saveClaim.setCustomerCode(bo.getCustomerCode());
        saveClaim.setMcustomerCode(bo.getMcustomerCode());
        saveClaim.setCustomerName(bo.getCustomerName());
        saveClaim.setMerchantNo(bo.getMerchantNo());
        saveClaim.setMerchantName(bo.getMerchantName());
        saveClaim.setBusinessNo(bo.getBusinessNo());
        saveClaim.setReceiveAcc(bo.getReceiveAcc());
        saveClaim.setClaimAmount(bo.getClaimAmount());
        saveClaim.setCcy(bo.getCcy());
        saveClaim.setPurposes(bo.getPurposes());
        saveClaim.setClaimType(bo.getClaimType());
        saveClaim.setBalance(bo.getBalance());
        saveClaim.setClaimDate(bo.getClaimDate());
        saveClaim.setStatus(bo.getStatus());
        saveClaim.setRepaymentStatus(bo.getRepaymentStatus());
        int count = this.baseMapper.insert(saveClaim);
        if (count != 1) {
            return ResultEx.fail();
        }

        return ResultEx.ok(saveClaim);
    }

    public IPage<InwardClaimPageListKo> pageQuery(QueryInwardClaimPageListBo bo) {
        return this.baseMapper.pageQuery(PageUtil.initPage(bo), bo);

    }

}
